from pydantic import BaseModel, Field
from datetime import datetime
from typing import Optional, List, Union, Any, Dict

# API响应标准格式
class APIResponse(BaseModel):
    code: int = 200
    message: str = "操作成功"
    data: Optional[Any] = None

# 共享的基础消息模型
class MessageBase(BaseModel):
    id: int
    type: int  # 0: 文本, 1: 图片, 2: 音频, 3: 文件
    text: Optional[str] = None
    image: Optional[str] = None
    audio: Optional[str] = None
    file: Optional[str] = None
    status: int
    createdAt: str  # 格式化的时间字符串
    userId: int
    nickname: str
    avatar: Optional[str] = None
    sex: int
    email: Optional[str] = None

# 共享的基础好友模型
class FriendBase(BaseModel):
    id: int
    remark: Optional[str] = None
    userId: int
    nickname: str
    avatar: Optional[str] = None
    sex: int
    online: int
    email: Optional[str] = None
    last_at: Optional[datetime] = None
    created_at: Optional[datetime] = None

# 共享的基础群组模型
class GroupBase(BaseModel):
    id: int
    name: str
    avatar: Optional[str] = None 